<?php
require $_SERVER["DOCUMENT_ROOT"] . "/aonce_connect.php";
$idpic = isset($_GET["pic"]) ? $_GET["pic"] : NULL;
if($idpic == NULL)
	$idpic = isset($_POST["pic"]) ? $_POST["pic"] : NULL;


$delpic_query = "DELETE FROM picsser WHERE idpicsser=$idpic;";
//echo $delpic_query;

$idpic_fields = "fotopicsser, serie";
$idpic_query = "SELECT $idpic_fields FROM picsser WHERE idpicsser=$idpic;";
//echo $idpic_query;

/*
 * Conexion a DB y ejecuci'on de queries
 */
$link = conecta();
$idpic_result = $link->query($idpic_query);
$delpic_result = $link->query($delpic_query);
//var_dump($link);
$link->close();

//echo "FETCH";
$idpic_data = $idpic_result->fetch_assoc();
var_dump($idpic_data);
$idserie = $idpic_data["serie"];
$myFile = $_SERVER["DOCUMENT_ROOT"] . $parent_dir ."/uploads/" . $idpic_data["fotopicsser"];
$fh = fopen($myFile, 'w') or die("can't open file $myFile");
fclose($fh);
unlink($myFile);

$myFile = $_SERVER["DOCUMENT_ROOT"] . $parent_dir ."/thumbs/" . $idpic_data["fotopicsser"];
$fh = fopen($myFile, 'w') or die("can't open file $myFile");
fclose($fh);
unlink($myFile);

printf("<script language=\"javascript\">\ndocument.location=\"nuevaSerie.php?serie=%d\";\n</script>\n", $idserie);


?>
